package com.meitutest.autoscript.fluency;

import android.os.Bundle;
import android.support.test.InstrumentationRegistry;
import android.text.TextUtils;

/**
 * <p>用于进程间的传参</p>
 * <b>注意：</b>需要两个工程保持一致
 */

public class CommonArgs {

    public static String directionName = "direction";
    public static String countsName = "counts";
    public static String stepName = "step";

    public static Direction DIRECT;
    public static int counts;
    public static int step;

    public static void initArgs() {
        Bundle bundle = InstrumentationRegistry.getArguments();
        String d = bundle.getString(directionName);
        String c = bundle.getString(countsName);
        String s = bundle.getString(stepName);
        if (TextUtils.isEmpty(d)) {
            DIRECT = Direction.fromBottom;
        } else {
            if (d.equals(Direction.fromBottom.toString())) {
                DIRECT = Direction.fromBottom;
            } else if (d.equals(Direction.fromTop.toString())) {
                DIRECT = Direction.fromTop;
            } else if (d.equals(Direction.fromLeft.toString())) {
                DIRECT = Direction.fromLeft;
            } else if (d.equals(Direction.fromRight.toString())) {
                DIRECT = Direction.fromRight;
            } else {
                DIRECT = Direction.fromBottom;
            }
        }
        if (TextUtils.isEmpty(c)) {
            counts = 10;
        } else {
            counts = Integer.parseInt(c);
        }
        if (TextUtils.isEmpty(s)) {
            step = 50;
        } else {
            step = Integer.parseInt(s);
        }

    }

}
